home *** CD-ROM | disk | FTP | other *** search
- Path: bright.ecs.soton.ac.uk!postmaster
- From: Alan Williams <acw93r@ecs.soton.ac.uk>
- Newsgroups: comp.lang.c++
- Subject: Problem inheriting protected types
- Date: Thu, 08 Feb 1996 10:44:31 +0000
- Organization: Southampton University
- Message-ID: <3119D40F.7847@ecs.soton.ac.uk>
- NNTP-Posting-Host: mars.ecs.soton.ac.uk
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (Win95; I)
-
- Hi all,
-
- I wonder if anyone can shed some light on this problem for me in the
- following code fragment compiled on BC++ 4.52:
-
- class X { // base class
- protected :
- enum Lst {ONE,TWO,THREE};
- };
-
- class Y : public X { // derived class: X protected now Y protected
- public :
- void test(int n) { z.a=TWO; }
-
- private :
- Lst y; // type Lst derived in X - OK
- struct Jim {
- Lst a; // type Lst derived in X - DOESN'T COMPILE
- } z;
- };
-
- void main()
- {
- Y n;
- n.test(42);
- }
-
- I'm trying to use enum type Lst in a privately (or protected)
- declared class in the derived class. Using Lst directly for a member
- works fine, but using it in a sub-class will not compile saying X::Lst
- is not visible. I've tried all sorts, it only works if its declared
- public in X which I dont want. What is wrong ???
-
- Alan
-